package utils;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

public class JsoupUtils {
    public static void main(String[] args) {
        String str = "<p>看看html代码</p>\n" +
                "<p><img class=\"key-mat-block\" key-mat-id=\"617\" style=\"max-width: 100%\"\n" +
                "        src=\"http://dbxz1-hw.ahtv.cn/article/20201110195923/488eb2f858864cad8cd7181cf95ce3b2.jpg\"></p>\n" +
                "<p><video class=\"key-mat-block\" key-mat-id=\"618\" tppe=\"video/mp4\" controls=\"controls\" style=\"max-width: 100%\"\n" +
                "        src=\"https://ahtv-obs.obs.cn-north-4.myhuaweicloud.com/ahtv-transcoding/20201105/de22d651-bb93-84ae-f515-03f777adbc26_H.265_1920x1080_AAC_2474.mp4\"></video>\n" +
                "</p>\n" +
                "<p><br></p>\n" +
                "<p><br></p>\n" +
                "<p><audio class=\"key-mat-block\" key-mat-id=\"305\" controls=\"\" style=\"max-width: 100%\"\n" +
                "        src=\"https://ahtv-obs.obs.cn-north-4.myhuaweicloud.com/ahtv-obs/20201010/11d1d494-400c-f6ea-ea13-1118b39decb7.mp3\"></audio>\n" +
                "</p>\n" +
                "<p><br></p>\n" +
                "<p><br></p>";

        Document doc = Jsoup.parse(str);
        String imgUrl = doc.select("img").attr("src");
        String videoUrl = doc.select("video").attr("src");
        String audioUrl = doc.select("audio").attr("src");
        System.out.println("imgUrl = " + imgUrl);
        System.out.println("videoUrl = " + videoUrl);
        System.out.println("audioUrl = " + audioUrl);
    }
}
